home *** CD-ROM | disk | FTP | other *** search
/ Champak 142 / Volume 142 Oct 17 2011 - Damaged.iso / Interface / it.dig / scripts / __Packages / mx / core / ExternalContent.as next >
Text File  |  2011-10-17  |  5KB  |  152 lines

  1. class mx.core.ExternalContent
  2. {
  3.    static var classConstructed = mx.core.ExternalContent.classConstruct();
  4.    static var ViewDependency = mx.core.View;
  5.    function ExternalContent()
  6.    {
  7.    }
  8.    function loadExternal(url, placeholderClassName, instanceName, depth, initProps)
  9.    {
  10.       var _loc2_ = undefined;
  11.       _loc2_ = this.createObject(placeholderClassName,instanceName,depth,initProps);
  12.       this[mx.core.View.childNameBase + this.numChildren] = _loc2_;
  13.       if(this.prepList == undefined)
  14.       {
  15.          this.prepList = new Object();
  16.       }
  17.       this.prepList[instanceName] = {obj:_loc2_,url:url,complete:false,initProps:initProps};
  18.       this.prepareToLoadMovie(_loc2_);
  19.       return _loc2_;
  20.    }
  21.    function prepareToLoadMovie(obj)
  22.    {
  23.       obj.unloadMovie();
  24.       this.doLater(this,"waitForUnload");
  25.    }
  26.    function waitForUnload()
  27.    {
  28.       var _loc3_ = undefined;
  29.       for(_loc3_ in this.prepList)
  30.       {
  31.          var _loc2_ = this.prepList[_loc3_];
  32.          if(_loc2_.obj.getBytesTotal() == 0)
  33.          {
  34.             if(this.loadList == undefined)
  35.             {
  36.                this.loadList = new Object();
  37.             }
  38.             this.loadList[_loc3_] = _loc2_;
  39.             _loc2_.obj.loadMovie(_loc2_.url);
  40.             delete this.prepList[_loc3_];
  41.             this.doLater(this,"checkLoadProgress");
  42.          }
  43.          else
  44.          {
  45.             this.doLater(this,"waitForUnload");
  46.          }
  47.       }
  48.    }
  49.    function checkLoadProgress()
  50.    {
  51.       var _loc8_ = false;
  52.       var _loc3_ = undefined;
  53.       for(_loc3_ in this.loadList)
  54.       {
  55.          var _loc2_ = this.loadList[_loc3_];
  56.          _loc2_.loaded = _loc2_.obj.getBytesLoaded();
  57.          _loc2_.total = _loc2_.obj.getBytesTotal();
  58.          if(_loc2_.total > 0)
  59.          {
  60.             _loc2_.obj._visible = false;
  61.             this.dispatchEvent({type:"progress",target:_loc2_.obj,current:_loc2_.loaded,total:_loc2_.total});
  62.             if(_loc2_.loaded == _loc2_.total)
  63.             {
  64.                if(this.loadedList == undefined)
  65.                {
  66.                   this.loadedList = new Object();
  67.                }
  68.                this.loadedList[_loc3_] = _loc2_;
  69.                delete this.loadList[_loc3_];
  70.                this.doLater(this,"contentLoaded");
  71.             }
  72.          }
  73.          else if(_loc2_.total == -1)
  74.          {
  75.             if(_loc2_.failedOnce != undefined)
  76.             {
  77.                _loc2_.failedOnce = _loc2_.failedOnce + 1;
  78.                if(_loc2_.failedOnce > 3)
  79.                {
  80.                   this.dispatchEvent({type:"complete",target:_loc2_.obj,current:_loc2_.loaded,total:_loc2_.total});
  81.                   delete this.loadList[_loc3_];
  82.                   false;
  83.                }
  84.             }
  85.             else
  86.             {
  87.                _loc2_.failedOnce = 0;
  88.             }
  89.          }
  90.          _loc8_ = true;
  91.       }
  92.       if(_loc8_)
  93.       {
  94.          this.doLater(this,"checkLoadProgress");
  95.       }
  96.    }
  97.    function contentLoaded()
  98.    {
  99.       var _loc4_ = undefined;
  100.       for(_loc4_ in this.loadedList)
  101.       {
  102.          var _loc2_ = this.loadedList[_loc4_];
  103.          _loc2_.obj._visible = true;
  104.          _loc2_.obj._complete = true;
  105.          var _loc3_ = undefined;
  106.          for(_loc3_ in _loc2_.initProps)
  107.          {
  108.             _loc2_.obj[_loc3_] = _loc2_.initProps[_loc3_];
  109.          }
  110.          this.childLoaded(_loc2_.obj);
  111.          this.dispatchEvent({type:"complete",target:_loc2_.obj,current:_loc2_.loaded,total:_loc2_.total});
  112.          delete this.loadedList[_loc4_];
  113.          false;
  114.       }
  115.    }
  116.    function convertToUIObject(obj)
  117.    {
  118.       if(obj.setSize == undefined)
  119.       {
  120.          var _loc2_ = mx.core.UIObject.prototype;
  121.          obj.addProperty("width",_loc2_.__get__width,null);
  122.          obj.addProperty("height",_loc2_.__get__height,null);
  123.          obj.addProperty("left",_loc2_.__get__left,null);
  124.          obj.addProperty("x",_loc2_.__get__x,null);
  125.          obj.addProperty("top",_loc2_.__get__top,null);
  126.          obj.addProperty("y",_loc2_.__get__y,null);
  127.          obj.addProperty("right",_loc2_.__get__right,null);
  128.          obj.addProperty("bottom",_loc2_.__get__bottom,null);
  129.          obj.addProperty("visible",_loc2_.__get__visible,_loc2_.__set__visible);
  130.          obj.move = mx.core.UIObject.prototype.move;
  131.          obj.setSize = mx.core.UIObject.prototype.setSize;
  132.          obj.size = mx.core.UIObject.prototype.size;
  133.          mx.events.UIEventDispatcher.initialize(obj);
  134.       }
  135.    }
  136.    static function enableExternalContent()
  137.    {
  138.    }
  139.    static function classConstruct()
  140.    {
  141.       var _loc1_ = mx.core.View.prototype;
  142.       var _loc2_ = mx.core.ExternalContent.prototype;
  143.       _loc1_.loadExternal = _loc2_.loadExternal;
  144.       _loc1_.prepareToLoadMovie = _loc2_.prepareToLoadMovie;
  145.       _loc1_.waitForUnload = _loc2_.waitForUnload;
  146.       _loc1_.checkLoadProgress = _loc2_.checkLoadProgress;
  147.       _loc1_.contentLoaded = _loc2_.contentLoaded;
  148.       _loc1_.convertToUIObject = _loc2_.convertToUIObject;
  149.       return true;
  150.    }
  151. }
  152.